package com.client.mapper;

import com.Emplyment.entity.Article;
import com.Emplyment.entity.QuestionBank;
import com.Emplyment.entity.QuetionCollect;
import com.Emplyment.vo.QuestionBankVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface QuestionBankMapper {

    @Select("SELECT * FROM question_bank where category = #{selectedCareer}")
    List<QuestionBankVo> getQuestionBank(String selectedCareer);

    @Update("UPDATE question_bank SET collect_num = 1")
    void updateCollectNum();


    @Select("select count(*) from questionbank_collect where quetionbank_id = #{questionId} and username = #{username}")
    Integer getCollectStatus(Integer questionId, String username);

    @Insert("insert into questionbank_collect(quetionbank_id, username) values(#{quetionbankId}, #{username})")
    void collect(QuetionCollect quetionCollect);

    @Delete("delete from questionbank_collect where quetionbank_id = #{quetionbankId} and username = #{username}")
    void cancelCollect(QuetionCollect quetionCollect);

    @Update("update question_bank set collect_num = collect_num + 1 where id = #{questionId}")
    void addCollectCount(Integer questionId);

    @Update("update question_bank set collect_num = collect_num - 1 where id = #{questionId}")
    void cancelCollectCount(Integer questionId);

    @Select("select * from question_bank where id = #{questionId}")
    QuestionBank getQuestionById(Integer questionId);

    @Select("select * from question_bank order by collect_num desc , updateTime desc limit 100")
    List<QuestionBank> getHotQuestions();

    @Select("select category from question_bank group by category")
    List<String> getAllCareer();
}
